package com.newtouch.bxzs.business.train.controller;

import com.newtouch.bxzs.business.config.MyLog;
import com.newtouch.bxzs.business.train.model.bo.ExaminationPaperBaseInfoDetailBO;
import com.newtouch.bxzs.business.train.model.bo.ExaminationPaperForExaminationBO;
import com.newtouch.bxzs.business.train.model.bo.ExaminationPaperPCListBO;
import com.newtouch.bxzs.business.train.model.vo.ChangeExaminationPaperStateVO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationPaperForExaminationListVO;
import com.newtouch.bxzs.business.train.model.vo.ExaminationPaperPCListVO;
import com.newtouch.bxzs.business.train.model.vo.ModifyExaminationPaperBaseInfoVO;
import com.newtouch.bxzs.business.train.service.ExaminationPaperService;
import com.newtouch.bxzs.common.base.response.BaseResponse;
import com.newtouch.bxzs.common.base.response.RespGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 考试试卷的controller类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/21</td>
 * <td>lanwei</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author lanwei
 * @version 1.0.0
 * @since 1.0.0
 */
@Api(tags = "试卷管理")
@RestController
@RequestMapping("/examinationPaperController")
@SuppressWarnings("unchecked")
public class ExaminationPaperController {

    /**
     * 静态变量：系统日志
     */
    private static final Log logger = LogFactory.getLog(ExaminationPaperController.class);

    @Autowired
    private ExaminationPaperService examinationPaperService;

    @ApiOperation(value = "考试设置时查看试卷列表")
    @PostMapping("/getExaminationPaperForExaminationList")
    public BaseResponse<ExaminationPaperForExaminationBO> getExaminationPaperForExaminationList(
            @RequestBody @ApiParam(name = "examinationPaperForExaminationListVO", value = "查看PC考试时的试卷列表VO类", required = true) ExaminationPaperForExaminationListVO examinationPaperForExaminationListVO) {
        logger.info("PC考试设置时查看试卷列表");
        return RespGenerator.returnOK(
                examinationPaperService.getExaminationPaperForExamination(examinationPaperForExaminationListVO));
    }

    /**
     * 查询试卷列表
     *
     * @param examinationPaperPCListVO 查询试卷列表VO
     * @return ExaminationPaperPCListBO
     */
    @ApiOperation(value = "查询试卷列表")
    @PostMapping("/getExaminationPaperPCList")
    @MyLog(systemFunctionName = "试卷管理", systemFunctionUrl = "/examinationPaperController/getExaminationPaperPCList", userOperationType = 4, userOperationSummary = "查询试卷列表")
    public BaseResponse<ExaminationPaperPCListBO> getExaminationPaperPCList(
            @RequestBody @ApiParam(name = "examinationPaperPCListVO", value = "查询试卷列表VO类", required = true) ExaminationPaperPCListVO examinationPaperPCListVO) {
        logger.info("查询试卷列表");
        return RespGenerator.returnOK(examinationPaperService.getExaminationPaperPCList(examinationPaperPCListVO));
    }

    /**
     * 创建、修改试卷信息
     *
     * @param examinationPaperBaseInfoVO 创建或修改试卷基本信息VO
     * @return String
     */
    @ApiOperation(value = "创建或修改试卷基本信息")
    @PostMapping("/modifyExaminationPaperBaseInfoVO")
    @MyLog(systemFunctionName = "试卷管理", systemFunctionUrl = "/examinationPaperController/modifyExaminationPaperBaseInfoVO", userOperationType = 5, userOperationSummary = "创建或修改试卷基本信息")
    public BaseResponse<String> modifyExaminationPaperBaseInfo(
            @RequestBody @ApiParam(name = "examinationPaperBaseInfoVO", value = "试卷基础信息VO类", required = true) ModifyExaminationPaperBaseInfoVO examinationPaperBaseInfoVO) {
        logger.info("创建或修改试卷基本信息");
        return RespGenerator
                .returnOK(examinationPaperService.modifyExaminationPaperBaseInfo(examinationPaperBaseInfoVO));
    }

    /**
     * 启用、禁用、作废试卷
     *
     * @param examinationPaperStateVO 启用、禁用、作废试卷VO
     * @return String
     */
    @ApiOperation(value = "启用、禁用、作废试卷")
    @PostMapping("/changeExaminationPaperState")
    @MyLog(systemFunctionName = "试卷管理", systemFunctionUrl = "/examinationPaperController/changeExaminationPaperState", userOperationType = 5, userOperationSummary = "启用、禁用、作废试卷")
    public BaseResponse<String> changeExaminationPaperState(
            @RequestBody @ApiParam(name = "examinationPaperStateVO", value = "启用、禁用、作废试卷VO类", required = true) ChangeExaminationPaperStateVO examinationPaperStateVO) {
        logger.info("启用、禁用、作废试卷");
        return RespGenerator.returnOK(examinationPaperService.changeExaminationPaperState(examinationPaperStateVO));
    }

    /**
     * 删除试卷
     *
     * @param examinationPaperIds 试卷Id集合
     * @return Integer
     */
    @ApiOperation(value = "删除试卷")
    @PostMapping("/deleteExaminationPaper")
    @MyLog(systemFunctionName = "试卷管理", systemFunctionUrl = "/examinationPaperController/deleteExaminationPaper", userOperationType = 3, userOperationSummary = "删除试卷")
    public BaseResponse<Integer> deleteExaminationPaper(
            @RequestBody @ApiParam(name = "examinationPaperIds", value = "试卷id集合", required = true) List<String> examinationPaperIds) {
        logger.info("删除试卷");
        return RespGenerator.returnOK(examinationPaperService.deleteExaminationPaper(examinationPaperIds));
    }

    /**
     * 查询试卷详情
     *
     * @param examinationPaperId 试卷Id
     * @return ExaminationPaperBaseInfoDetailBO
     */
    @ApiOperation(value = "查询试卷详情")
    @GetMapping("/getExaminationPaperBaseInfo")
    @MyLog(systemFunctionName = "试卷管理", systemFunctionUrl = "/examinationPaperController/getExaminationPaperBaseInfo", userOperationType = 4, userOperationSummary = "查询试卷详情")
    public BaseResponse<ExaminationPaperBaseInfoDetailBO> getExaminationPaperBaseInfo(
            @RequestParam(value = "examinationPaperId") @ApiParam(name = "examinationPaperId", value = "试卷Id", required = true) String examinationPaperId) {
        logger.info("查询试卷详情");
        return RespGenerator.returnOK(examinationPaperService.getExaminationPaperBaseInfo(examinationPaperId));
    }
}
